/*[[ Name := Fisher Separate Window := Yes First Color := Lime First Draw Type := Histogram First Symbol := 217 Use Second Data := Yes Second Color := Red Second Draw Type := Histogram Second Symbol := 218 ]]*/ //******** Parameters ******** Input : nBars(10), Mark(1); //******** Variables ******** Variables : bar(0), prevbars(0), start(0), cs(0), prevcs(0); Variables : P(0), Value(0), Fish(0), MaxH(0), MinL(0),AlertTime(0); Variables : Value1(0), Fish1(0), Fish2(0), i(0), pFish(0); //Initialisation setloopcount(0); cs=nBars+Mark; //checksum used to see if parameters have been changed if cs=prevcs then start=Bars-prevbars //params haven't changed only need to calculate new bar else start=-1; prevbars = Bars; prevcs = cs; if start=1 | start=0 then bar+=start else //if number of new bars is >1 or <0 then re-calculatge entire chart { bar = Bars; For i=1 to nBars { bar-=1; SetIndexValue(bar,0); }; Value=0; Fish=0; Fish1=0; }; While bar>1 {//per bar jobs bar -=1; //Fish formulae courtesy of:- //http://www.linnsoft.com/tour/techind/fish.htm Value1 = Value; Fish2 = Fish1; Fish1 = Fish; MaxH=H[Highest(MODE_HIGH,bar+nBars-1,nBars)]; MinL=L[Lowest(MODE_LOW,bar+nBars-1,nBars)]; P=(H[bar]+L[bar])/2; Value = 0.33*2*((P-MinL)/(MaxH-MinL)-0.5) + 0.67*Value1; Value=Min(Max(Value,-0.999),0.999); //bounds checking Fish = 0.5*Log((1+Value)/(1-Value))+0.5*Fish1; If Fish > pFish Then SetIndexValue(bar, Fish); If Fish < pFish Then SetIndexValue2(bar, Fish); If Mark>0 Then{ If Fish<-1 & Fish>Fish1 & Fish1<=Fish2 Then SetArrow(Time[bar],L[bar],159,LIME); If Fish>1 & Fish=Fish2 Then SetArrow(Time[bar],H[bar],159,RED); } Else{ DelArrow(Time[bar],L[bar]); DelArrow(Time[bar],H[bar]); }; pFish = Fish; }; if CurTime > AlertTime then { If Fish<-1 & Fish>Fish1 & Fish1<=Fish2 Then { Alert(Symbol, ", M", Period, ": BUY Signal."); AlertTime = CurTime + (Period - mod(Minute, Period))*60; }; If Fish>1 & Fish=Fish2 Then { Alert(Symbol, ", M", Period, ": SELL Signal."); AlertTime = CurTime + (Period - mod(Minute, Period))*60; }; }; //per tick jobs //- we don't have any //End;